Skip to content

Commit

Permalink
fix(16054): replaces ReactNodeLike with ReactNode (#16465)
Browse files Browse the repository at this point in the history
  • Loading branch information
2nikhiltom authored May 15, 2024
1 parent 1771cb6 commit 0d27e71
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 31 deletions.
9 changes: 5 additions & 4 deletions packages/react/src/components/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import PropTypes, { ReactNodeLike } from 'prop-types';
import PropTypes from 'prop-types';
import React, {
useContext,
useEffect,
Expand All @@ -14,6 +14,7 @@ import React, {
useCallback,
useState,
ForwardedRef,
ReactNode,
} from 'react';
import cx from 'classnames';
import flatpickr from 'flatpickr';
Expand Down Expand Up @@ -215,7 +216,7 @@ interface DatePickerProps {
/**
* The child nodes.
*/
children: React.ReactNode | object;
children: ReactNode | object;

/**
* The CSS class names.
Expand Down Expand Up @@ -264,7 +265,7 @@ interface DatePickerProps {
/**
* Provide the text that is displayed when the control is in error state (Fluid Only)
*/
invalidText?: ReactNodeLike;
invalidText?: ReactNode;

/**
* `true` to use the light version.
Expand Down Expand Up @@ -396,7 +397,7 @@ interface DatePickerProps {
/**
* Provide the text that is displayed when the control is in warning state (Fluid only)
*/
warnText?: ReactNodeLike;
warnText?: ReactNode;
}

const DatePicker = React.forwardRef(function DatePicker(
Expand Down
12 changes: 6 additions & 6 deletions packages/react/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
UseSelectStateChangeTypes,
} from 'downshift';
import cx from 'classnames';
import PropTypes, { ReactNodeLike } from 'prop-types';
import PropTypes from 'prop-types';
import {
Checkmark,
WarningAltFilled,
Expand Down Expand Up @@ -111,7 +111,7 @@ export interface DropdownProps<ItemType>
* Provide helper text that is used alongside the control label for
* additional help
*/
helperText?: React.ReactNode;
helperText?: ReactNode;

/**
* Specify whether the title text should be hidden or not
Expand All @@ -137,7 +137,7 @@ export interface DropdownProps<ItemType>
/**
* Message which is displayed if the value is invalid.
*/
invalidText?: React.ReactNode;
invalidText?: ReactNode;

/**
* Function to render items as custom components instead of strings.
Expand Down Expand Up @@ -201,13 +201,13 @@ export interface DropdownProps<ItemType>
/**
* **Experimental**: Provide a `Slug` component to be rendered inside the `Dropdown` component
*/
slug?: ReactNodeLike;
slug?: ReactNode;

/**
* Provide the title text that will be read by a screen reader when
* visiting this control
*/
titleText?: React.ReactNode;
titleText?: ReactNode;

/**
* Callback function for translating ListBoxMenuIcon SVG title
Expand All @@ -230,7 +230,7 @@ export interface DropdownProps<ItemType>
/**
* Provide the text that is displayed when the control is in warning state
*/
warnText?: React.ReactNode;
warnText?: ReactNode;
}

export type DropdownTranslationKey = ListBoxMenuIconTranslationKey;
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/components/IconButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import PropTypes, { ReactNodeLike } from 'prop-types';
import React, { ForwardedRef } from 'react';
import PropTypes from 'prop-types';
import React, { ForwardedRef, ReactNode } from 'react';
import { ButtonSize } from '../Button';
import classNames from 'classnames';
import { Tooltip } from '../Tooltip';
Expand Down Expand Up @@ -44,7 +44,7 @@ interface IconButtonProps
/**
* Provide an icon or asset to be rendered inside of the IconButton
*/
children?: React.ReactNode;
children?: ReactNode;

/**
* Specify an optional className to be added to your Button
Expand Down Expand Up @@ -88,7 +88,7 @@ interface IconButtonProps
* This means that if you have text in the child node it will not be
* announced to the screen reader.
*/
label: ReactNodeLike;
label: ReactNode;

/**
* Specify the duration in milliseconds to delay before hiding the tooltip
Expand Down
20 changes: 10 additions & 10 deletions packages/react/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import PropTypes, { ReactNodeLike } from 'prop-types';
import React, { useRef, useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import React, { useRef, useEffect, useState, ReactNode } from 'react';
import classNames from 'classnames';
import { Close } from '@carbon/icons-react';
import toggleClass from '../../tools/toggleClass';
Expand Down Expand Up @@ -37,7 +37,7 @@ export const ModalSizes = ['xs', 'sm', 'md', 'lg'] as const;
export type ModalSize = (typeof ModalSizes)[number];

export interface ModalSecondaryButton {
buttonText?: string | React.ReactNode;
buttonText?: string | ReactNode;

onClick?: React.MouseEventHandler<HTMLButtonElement>;
}
Expand All @@ -57,7 +57,7 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
/**
* Provide the contents of your Modal
*/
children?: React.ReactNode;
children?: ReactNode;

/**
* Specify an optional className to be applied to the modal root node
Expand Down Expand Up @@ -117,12 +117,12 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
/**
* Specify the content of the modal header title.
*/
modalHeading?: React.ReactNode;
modalHeading?: ReactNode;

/**
* Specify the content of the modal header label.
*/
modalLabel?: React.ReactNode;
modalLabel?: ReactNode;

/**
* Specify a handler for keypresses.
Expand Down Expand Up @@ -177,12 +177,12 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
/**
* Specify the text for the primary button
*/
primaryButtonText?: React.ReactNode;
primaryButtonText?: ReactNode;

/**
* Specify the text for the secondary button
*/
secondaryButtonText?: React.ReactNode;
secondaryButtonText?: ReactNode;

/**
* Specify an array of config objects for secondary buttons
Expand Down Expand Up @@ -214,7 +214,7 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
/**
* **Experimental**: Provide a `Slug` component to be rendered inside the `Modal` component
*/
slug?: ReactNodeLike;
slug?: ReactNode;
}

const Modal = React.forwardRef(function Modal(
Expand Down Expand Up @@ -372,7 +372,7 @@ const Modal = React.forwardRef(function Modal(
Array.isArray(secondaryButtons) && secondaryButtons.length === 2,
});

const asStringOrUndefined = (node: React.ReactNode): string | undefined => {
const asStringOrUndefined = (node: ReactNode): string | undefined => {
return typeof node === 'string' ? node : undefined;
};
const modalLabelStr = asStringOrUndefined(modalLabel);
Expand Down
15 changes: 8 additions & 7 deletions packages/react/src/components/MultiSelect/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ import {
UseSelectStateChangeTypes,
} from 'downshift';
import isEqual from 'lodash.isequal';
import PropTypes, { ReactNodeLike } from 'prop-types';
import PropTypes from 'prop-types';
import React, {
ForwardedRef,
useContext,
useRef,
useState,
useMemo,
ReactNode,
} from 'react';
import ListBox, {
ListBoxSize,
Expand Down Expand Up @@ -182,7 +183,7 @@ export interface MultiSelectProps<ItemType>
* Provide helper text that is used alongside the control label for
* additional help
*/
helperText?: React.ReactNode;
helperText?: ReactNode;

/**
* Specify whether the title text should be hidden or not
Expand All @@ -208,7 +209,7 @@ export interface MultiSelectProps<ItemType>
/**
* If invalid, what is the error?
*/
invalidText?: React.ReactNode;
invalidText?: ReactNode;

/**
* Function to render items as custom components instead of strings.
Expand All @@ -233,7 +234,7 @@ export interface MultiSelectProps<ItemType>
* Generic `label` that will be used as the textual representation of what
* this field is for
*/
label: NonNullable<React.ReactNode>;
label: NonNullable<ReactNode>;

/**
* `true` to use the light version.
Expand Down Expand Up @@ -292,13 +293,13 @@ export interface MultiSelectProps<ItemType>
/**
* **Experimental**: Provide a `Slug` component to be rendered inside the `MultiSelect` component
*/
slug?: ReactNodeLike;
slug?: ReactNode;

/**
* Provide text to be used in a `<label>` element that is tied to the
* multiselect via ARIA attributes.
*/
titleText?: React.ReactNode;
titleText?: ReactNode;

/**
* Specify 'inline' to create an inline multi-select.
Expand All @@ -318,7 +319,7 @@ export interface MultiSelectProps<ItemType>
/**
* Provide the text that is displayed when the control is in warning state
*/
warnText?: React.ReactNode;
warnText?: ReactNode;
}

const MultiSelect = React.forwardRef(
Expand Down

0 comments on commit 0d27e71

Please sign in to comment.