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

Update types and props for compatibility with React 18 #7150

Merged
merged 17 commits into from
Jan 11, 2025
Merged
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
2 changes: 1 addition & 1 deletion packages/core/src/components/context-menu/contextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export const ContextMenu: React.FC<ContextMenuProps> = React.forwardRef<any, Con
) : (
<>
{maybePopover}
{React.createElement<React.HTMLAttributes<any>>(
{React.createElement<React.HTMLAttributes<any> & React.ClassAttributes<any>>(
tagName,
{
className: containerClassName,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/entity-title/entityTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { type IconName, IconNames } from "@blueprintjs/icons";
import { Classes, DISPLAYNAME_PREFIX, type MaybeElement, type Props } from "../../common";
import { H1, H2, H3, H4, H5, H6 } from "../html/html";
import { Icon } from "../icon/icon";
import { Text } from "../text/text";
import { Text, type TextProps } from "../text/text";

export interface EntityTitleProps extends Props {
/**
Expand Down Expand Up @@ -177,7 +177,7 @@ EntityTitle.displayName = `${DISPLAYNAME_PREFIX}.EntityTitle`;
/**
* Construct header class name from H{*}. Returns `undefined` if `heading` is not a Blueprint heading.
*/
function getClassNameFromHeading(heading: React.FC<unknown>) {
function getClassNameFromHeading(heading: React.FC<TextProps>) {
const headerIndex = [H1, H2, H3, H4, H5, H6].findIndex(header => header === heading);
if (headerIndex < 0) {
return undefined;
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/components/hotkeys/hotkeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export interface HotkeysProps extends Props {
* the `tabIndex` from the component decorated by `HotkeysTarget`.
*/
tabIndex?: number;

/**
* An array of `Hotkey` components that define the hotkeys to be used.
*/
children?: React.ReactNode;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/components/html-select/htmlSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export interface HTMLSelectProps

/** Controlled value of this component. */
value?: string | number;

/** Placeholder text to display when no option is selected. */
placeholder?: string;
}

// this component is simple enough that tests would be purely tautological.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/overlay/overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class Overlay extends AbstractPureComponent<OverlayProps, OverlayState> {
});
}

private maybeRenderChild = (child?: React.ReactNode) => {
private maybeRenderChild = (child?: React.ReactNode | (() => React.ReactNode)) => {
if (isFunction(child)) {
child = child();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { DatePicker3Context } from "../date-picker3/datePicker3Context";
*
* @see https://daypicker.dev/guides/custom-components
*/
export const DatePicker3Caption: React.FC<CaptionProps> = props => {
export const DatePicker3Caption = (props: CaptionProps) => {
const { classNames: rdpClassNames, formatters, fromDate, toDate, labels } = useDayPicker();
const { locale, reverseMonthAndYearMenus } = React.useContext(DatePicker3Context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import { type Size, SizeSelect } from "./common/sizeSelect";

export const SegmentedControlExample: React.FC<ExampleProps> = props => {
const [intent, setIntent] = React.useState<SegmentedControlIntent>("none");
const handleIntentChange = React.useCallback(newIntent => setIntent(newIntent as SegmentedControlIntent), []);
const handleIntentChange = React.useCallback(
(newIntent: string) => setIntent(newIntent as SegmentedControlIntent),
[],
);

const [fill, setFill] = React.useState<boolean>(false);
const [inline, setInline] = React.useState<boolean>(false);
Expand Down
2 changes: 1 addition & 1 deletion packages/table/src/headers/columnHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface ColumnWidths {
defaultColumnWidth: number;
}

export interface ColumnHeaderProps extends HeaderProps, ColumnWidths, ColumnIndices {
export interface ColumnHeaderProps extends React.PropsWithChildren<HeaderProps>, ColumnWidths, ColumnIndices {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Similar comment around potentially writing the children field directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**
* A ColumnHeaderRenderer that, for each `<Column>`, will delegate to:
* 1. The `columnHeaderCellRenderer` method from the `<Column>`
Expand Down
5 changes: 5 additions & 0 deletions packages/table/src/headers/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ export interface HeaderProps extends LockableLayout, ReorderableProps, Selectabl
* or cancellation of a resize interaction.
*/
onResizeGuide: (guides: number[] | null) => void;

/**
* The content to be rendered inside the header.
*/
children?: React.ReactNode;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/table/src/headers/headerCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import * as React from "react";
import { ContextMenu, Classes as CoreClasses, Utils as CoreUtils, type Props } from "@blueprintjs/core";

import * as Classes from "../common/classes";
import type { ResizeHandle } from "../interactions/resizeHandle";

export interface HeaderCellProps extends Props {
children?: React.ReactNode;
Expand Down Expand Up @@ -66,7 +65,7 @@ export interface HeaderCellProps extends Props {
/**
* A `ResizeHandle` React component that allows users to drag-resize the header.
*/
resizeHandle?: ResizeHandle;
resizeHandle?: React.JSX.Element;

/**
* CSS styles for the top level element.
Expand Down