Skip to content

Commit

Permalink
[refactor] Replace global JSX with React.JSX
Browse files Browse the repository at this point in the history
The global JSX namespace has been removed in react 19.
See https://react.dev/blog/2024/04/25/react-19-upgrade-guide#the-jsx-namespace-in-typescript
  • Loading branch information
yesmeck committed Nov 27, 2024
1 parent c83f5b0 commit 9ab47ed
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { render } from '../render';

interface Options<Props = any> {
component: React.ComponentType<Props>;
props: Props & JSX.IntrinsicAttributes;
props: Props & React.JSX.IntrinsicAttributes;
error: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,6 @@ type FileInputComponent = (<Multiple extends boolean = false>(
props: FileInputProps<Multiple> & {
ref?: React.ForwardedRef<HTMLButtonElement>;
}
) => JSX.Element) & { extend: typeof _FileInput.extend };
) => React.JSX.Element) & { extend: typeof _FileInput.extend };

export const FileInput: FileInputComponent = _FileInput as any;
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface TransitionProps {
mounted: boolean;

/** Render function with transition styles argument */
children: (styles: React.CSSProperties) => JSX.Element;
children: (styles: React.CSSProperties) => React.JSX.Element;

/** Called when exit transition ends */
onExited?: () => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
type ExtendedProps<Props = {}, OverrideProps = {}> = OverrideProps &
Omit<Props, keyof OverrideProps>;

type ElementType = keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>;
type ElementType = keyof React.JSX.IntrinsicElements | React.JSXElementConstructor<any>;

type PropsOf<C extends ElementType> = JSX.LibraryManagedAttributes<
type PropsOf<C extends ElementType> = React.JSX.LibraryManagedAttributes<
C,
React.ComponentPropsWithoutRef<C>
>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const defaultProps: Partial<DatePickerProps> = {

type DatePickerComponent = (<Type extends DatePickerType = 'default'>(
props: DatePickerProps<Type> & { ref?: React.ForwardedRef<HTMLDivElement> }
) => JSX.Element) & { displayName?: string } & MantineComponentStaticProperties<DatePickerFactory>;
) => React.JSX.Element) & { displayName?: string } & MantineComponentStaticProperties<DatePickerFactory>;

export const DatePicker: DatePickerComponent = factory<DatePickerFactory>((_props, ref) => {
const props = useProps('DatePicker', defaultProps, _props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const defaultProps: Partial<DatePickerInputProps> = {

type DatePickerInputComponent = (<Type extends DatePickerType = 'default'>(
props: DatePickerInputProps<Type> & { ref?: React.ForwardedRef<HTMLButtonElement> }
) => JSX.Element) & {
) => React.JSX.Element) & {
displayName?: string;
} & MantineComponentStaticProperties<DatePickerInputFactory>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const defaultProps: Partial<MonthPickerProps> = {

type MonthPickerComponent = (<Type extends DatePickerType = 'default'>(
props: MonthPickerProps<Type> & { ref?: React.ForwardedRef<HTMLDivElement> }
) => JSX.Element) & { displayName?: string } & MantineComponentStaticProperties<MonthPickerFactory>;
) => React.JSX.Element) & { displayName?: string } & MantineComponentStaticProperties<MonthPickerFactory>;

export const MonthPicker: MonthPickerComponent = factory<MonthPickerFactory>((_props, ref) => {
const props = useProps('MonthPicker', defaultProps, _props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const defaultProps: Partial<MonthPickerInputProps> = {

type MonthPickerInputComponent = (<Type extends DatePickerType = 'default'>(
props: MonthPickerInputProps<Type> & { ref?: React.ForwardedRef<HTMLButtonElement> }
) => JSX.Element) & {
) => React.JSX.Element) & {
displayName?: string;
} & MantineComponentStaticProperties<MonthPickerInputFactory>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const defaultProps: Partial<YearPickerProps> = {

type YearPickerComponent = (<Type extends DatePickerType = 'default'>(
props: YearPickerProps<Type> & { ref?: React.ForwardedRef<HTMLDivElement> }
) => JSX.Element) & { displayName?: string } & MantineComponentStaticProperties<YearPickerFactory>;
) => React.JSX.Element) & { displayName?: string } & MantineComponentStaticProperties<YearPickerFactory>;

export const YearPicker: YearPickerComponent = factory<YearPickerFactory>((_props, ref) => {
const props = useProps('YearPicker', defaultProps, _props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const defaultProps: Partial<YearPickerInputProps> = {

type YearPickerInputComponent = (<Type extends DatePickerType = 'default'>(
props: YearPickerInputProps<Type> & { ref?: React.ForwardedRef<HTMLButtonElement> }
) => JSX.Element) & {
) => React.JSX.Element) & {
displayName?: string;
} & MantineComponentStaticProperties<YearPickerInputFactory>;

Expand Down
2 changes: 1 addition & 1 deletion packages/@mantine/dropzone/src/DropzoneStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function createDropzoneStatus(status: keyof DropzoneContextValue) {
const _children = isElement(children) ? children : <span>{children}</span>;

if (ctx[status]) {
return cloneElement(_children as JSX.Element, others);
return cloneElement(_children as React.JSX.Element, others);
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/@mantine/form/src/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface FormProps<Form extends UseFormReturnType<any>>

export type FormComponent = (<Form extends UseFormReturnType<any>>(
props: FormProps<Form>
) => JSX.Element | React.ReactNode) & { displayName?: string };
) => React.JSX.Element | React.ReactNode) & { displayName?: string };

export const Form: FormComponent = forwardRef(
<Form extends UseFormReturnType<any>>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function ConfiguratorDemo({
dimmed={dimmed}
striped={striped}
>
{cloneElement(children as JSX.Element, state)}
{cloneElement(children as React.JSX.Element, state)}
</DemoColumns>
<DemoCode code={getCodeArray({ code, controls, state })} />
</DemoRoot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function StylesApiDemo({
title="Component Styles API"
description="Hover over selectors to highlight corresponding elements"
>
{cloneElement(children as JSX.Element, {
{cloneElement(children as React.JSX.Element, {
classNames: selectors.reduce<Record<string, string>>((acc, item) => {
acc[item] = item;
return acc;
Expand Down

0 comments on commit 9ab47ed

Please sign in to comment.