Skip to content

Commit

Permalink
chore(types): update HTML attributes for React 19 compatibility (#2621)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpbl authored Dec 11, 2024
1 parent c9d0e41 commit 667be07
Show file tree
Hide file tree
Showing 24 changed files with 53 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { type ButtonHTMLAttributes } from "react";

/**
* Render the button elements in the calendar.
*
* @private
* @deprecated Use `PreviousMonthButton` or `@link NextMonthButton` instead.
*/
export function Button(props: JSX.IntrinsicElements["button"]) {
export function Button(props: ButtonHTMLAttributes<HTMLButtonElement>) {
return <button {...props} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/CaptionLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { type HTMLAttributes } from "react";

/**
* Render the label in the month caption.
*
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function CaptionLabel(props: JSX.IntrinsicElements["span"]) {
export function CaptionLabel(props: HTMLAttributes<HTMLSpanElement>) {
return <span {...props} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Day.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { type HTMLAttributes } from "react";

import type { CalendarDay } from "../classes/index.js";
import type { Modifiers } from "../types/index.js";
Expand All @@ -19,7 +19,7 @@ export function Day(
day: CalendarDay;
/** The modifiers to apply to the day. */
modifiers: Modifiers;
} & JSX.IntrinsicElements["td"]
} & HTMLAttributes<HTMLDivElement>
) {
const { day, modifiers, ...tdProps } = props;
return <td {...tdProps} />;
Expand Down
4 changes: 2 additions & 2 deletions src/components/DayButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { type ButtonHTMLAttributes } from "react";

import type { CalendarDay } from "../classes/index.js";
import type { Modifiers } from "../types/index.js";
Expand All @@ -15,7 +15,7 @@ export function DayButton(
day: CalendarDay;
/** The modifiers for the day. */
modifiers: Modifiers;
} & JSX.IntrinsicElements["button"]
} & ButtonHTMLAttributes<HTMLButtonElement>
) {
const { day, modifiers, ...buttonProps } = props;

Expand Down
4 changes: 2 additions & 2 deletions src/components/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { type SelectHTMLAttributes } from "react";

import { UI } from "../UI.js";
import type { ClassNames, CustomComponents } from "../types/index.js";
Expand Down Expand Up @@ -35,7 +35,7 @@ export function Dropdown(
*/
classNames: ClassNames;
options?: DropdownOption[] | undefined;
} & Omit<JSX.IntrinsicElements["select"], "children">
} & Omit<SelectHTMLAttributes<HTMLSelectElement>, "children">
) {
const { options, className, components, classNames, ...selectProps } = props;

Expand Down
4 changes: 2 additions & 2 deletions src/components/DropdownNav.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { type HTMLAttributes } from "react";

/**
* Render the the navigation dropdowns.
*
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function DropdownNav(props: JSX.IntrinsicElements["div"]) {
export function DropdownNav(props: HTMLAttributes<HTMLDivElement>) {
return <div {...props} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { type HTMLAttributes } from "react";

/**
* Component wrapping the footer.
*
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function Footer(props: JSX.IntrinsicElements["div"]) {
export function Footer(props: HTMLAttributes<HTMLDivElement>) {
return <div {...props} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Month.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { type HTMLAttributes } from "react";

import type { CalendarMonth } from "../classes/CalendarMonth.js";

Expand All @@ -15,7 +15,7 @@ export function Month(
calendarMonth: CalendarMonth;
/** The index where this month is displayed. */
displayIndex: number;
} & JSX.IntrinsicElements["div"]
} & HTMLAttributes<HTMLDivElement>
) {
const { calendarMonth, displayIndex, ...divProps } = props;
return <div {...divProps}>{props.children}</div>;
Expand Down
4 changes: 2 additions & 2 deletions src/components/MonthCaption.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { type HTMLAttributes } from "react";

import type { CalendarMonth } from "../classes/index.js";

Expand All @@ -14,7 +14,7 @@ export function MonthCaption(
calendarMonth: CalendarMonth;
/** The index where this month is displayed. */
displayIndex: number;
} & JSX.IntrinsicElements["div"]
} & HTMLAttributes<HTMLDivElement>
) {
const { calendarMonth, displayIndex, ...divProps } = props;
return <div {...divProps} />;
Expand Down
4 changes: 2 additions & 2 deletions src/components/MonthGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { type TableHTMLAttributes } from "react";

/**
* Render the grid of days in a month.
*
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function MonthGrid(props: JSX.IntrinsicElements["table"]) {
export function MonthGrid(props: TableHTMLAttributes<HTMLTableElement>) {
return <table {...props} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Months.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { type HTMLAttributes } from "react";

/**
* Component wrapping the month grids.
*
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function Months(props: JSX.IntrinsicElements["div"]) {
export function Months(props: HTMLAttributes<HTMLDivElement>) {
return <div {...props} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Nav.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { MouseEventHandler } from "react";
import React, { type MouseEventHandler, type HTMLAttributes } from "react";

import { UI } from "../UI.js";
import { useDayPicker } from "../useDayPicker.js";
Expand All @@ -15,7 +15,7 @@ export function Nav(
onNextClick?: MouseEventHandler<HTMLButtonElement>;
previousMonth?: Date | undefined;
nextMonth?: Date | undefined;
} & JSX.IntrinsicElements["nav"]
} & HTMLAttributes<HTMLElement>
) {
const {
onPreviousClick,
Expand Down
6 changes: 4 additions & 2 deletions src/components/NextMonthButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { type ButtonHTMLAttributes } from "react";

import { useDayPicker } from "../useDayPicker.js";

Expand All @@ -8,7 +8,9 @@ import { useDayPicker } from "../useDayPicker.js";
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function NextMonthButton(props: JSX.IntrinsicElements["button"]) {
export function NextMonthButton(
props: ButtonHTMLAttributes<HTMLButtonElement>
) {
const { components } = useDayPicker();
return <components.Button {...props} />;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Option.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { type OptionHTMLAttributes } from "react";

/**
* Render the `option` element.
*
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function Option(props: JSX.IntrinsicElements["option"]) {
export function Option(props: OptionHTMLAttributes<HTMLOptionElement>) {
return <option {...props} />;
}

Expand Down
6 changes: 4 additions & 2 deletions src/components/PreviousMonthButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { type ButtonHTMLAttributes } from "react";

import { useDayPicker } from "../useDayPicker.js";

Expand All @@ -8,7 +8,9 @@ import { useDayPicker } from "../useDayPicker.js";
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function PreviousMonthButton(props: JSX.IntrinsicElements["button"]) {
export function PreviousMonthButton(
props: ButtonHTMLAttributes<HTMLButtonElement>
) {
const { components } = useDayPicker();
return <components.Button {...props} />;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Root.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { type HTMLAttributes } from "react";

/**
* Render the root element.
*
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function Root(props: JSX.IntrinsicElements["div"]) {
export function Root(props: HTMLAttributes<HTMLDivElement>) {
return <div {...props} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { type SelectHTMLAttributes } from "react";

/**
* Render the `select` element.
*
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function Select(props: JSX.IntrinsicElements["select"]) {
export function Select(props: SelectHTMLAttributes<HTMLSelectElement>) {
return <select {...props} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Week.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { type HTMLAttributes } from "react";

import type { CalendarWeek } from "../classes/index.js";

Expand All @@ -11,7 +11,7 @@ import type { CalendarWeek } from "../classes/index.js";
export function Week(
props: {
week: CalendarWeek;
} & JSX.IntrinsicElements["tr"]
} & HTMLAttributes<HTMLTableRowElement>
) {
const { week, ...trProps } = props;
return <tr {...trProps} />;
Expand Down
4 changes: 2 additions & 2 deletions src/components/WeekNumber.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { type ThHTMLAttributes } from "react";

import type { CalendarWeek } from "../classes/index.js";

Expand All @@ -12,7 +12,7 @@ export function WeekNumber(
props: {
/** The week to render. */
week: CalendarWeek;
} & JSX.IntrinsicElements["th"]
} & ThHTMLAttributes<HTMLTableCellElement>
) {
const { week, ...thProps } = props;
return <th {...thProps} />;
Expand Down
6 changes: 4 additions & 2 deletions src/components/WeekNumberHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from "react";
import React, { type ThHTMLAttributes } from "react";

/**
* Render the column header for the week numbers.
*
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function WeekNumberHeader(props: JSX.IntrinsicElements["th"]) {
export function WeekNumberHeader(
props: ThHTMLAttributes<HTMLTableCellElement>
) {
return <th {...props} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Weekday.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { type ThHTMLAttributes } from "react";

/**
* Render the column header with the weekday name (e.g. "Mo", "Tu", etc.).
*
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function Weekday(props: JSX.IntrinsicElements["th"]) {
export function Weekday(props: ThHTMLAttributes<HTMLTableCellElement>) {
return <th {...props} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Weekdays.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { type HTMLAttributes } from "react";

/**
* Render the row with the weekday names.
*
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function Weekdays(props: JSX.IntrinsicElements["tr"]) {
export function Weekdays(props: HTMLAttributes<HTMLTableRowElement>) {
return (
<thead aria-hidden>
<tr {...props} />
Expand Down
4 changes: 2 additions & 2 deletions src/components/Weeks.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { type HTMLAttributes } from "react";

/**
* Render the weeks in the month grid.
*
* @group Components
* @see https://daypicker.dev/guides/custom-components
*/
export function Weeks(props: JSX.IntrinsicElements["tbody"]) {
export function Weeks(props: HTMLAttributes<HTMLTableSectionElement>) {
return <tbody {...props} />;
}

Expand Down
2 changes: 1 addition & 1 deletion website/src/components/BrowserWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function BrowserWindow({
style,
bodyStyle,
shadow = true
}: Props): JSX.Element {
}: Props) {
return (
<div className={styles.browserWindow} style={{ ...style, minHeight }}>
<div className={styles.browserWindowHeader}>
Expand Down

0 comments on commit 667be07

Please sign in to comment.