Skip to content

Commit 2dc412c

Browse files
chore: run react 19 codemods, bump mantine, fix type errors
1 parent 30c0771 commit 2dc412c

File tree

16 files changed

+147
-215
lines changed

16 files changed

+147
-215
lines changed

packages/mantine/package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@
5555
"monaco-editor": "0.52.0"
5656
},
5757
"devDependencies": {
58-
"@mantine/carousel": "7.14.3",
59-
"@mantine/code-highlight": "7.14.3",
60-
"@mantine/core": "7.14.3",
61-
"@mantine/dates": "7.14.3",
62-
"@mantine/form": "7.14.3",
63-
"@mantine/hooks": "7.14.3",
64-
"@mantine/modals": "7.14.3",
65-
"@mantine/notifications": "7.14.3",
58+
"@mantine/carousel": "7.15.1",
59+
"@mantine/code-highlight": "7.15.1",
60+
"@mantine/core": "7.15.1",
61+
"@mantine/dates": "7.15.1",
62+
"@mantine/form": "7.15.1",
63+
"@mantine/hooks": "7.15.1",
64+
"@mantine/modals": "7.15.1",
65+
"@mantine/notifications": "7.15.1",
6666
"@swc/cli": "0.5.2",
6767
"@swc/core": "1.9.3",
6868
"@testing-library/dom": "10.4.0",

packages/mantine/src/__tests__/Utils.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {FunctionComponent, PropsWithChildren, ReactElement} from 'react';
44

55
import {Plasmantine} from '../theme';
66

7-
const customRender = (ui: ReactElement, options?: Omit<RenderOptions, 'queries'>): RenderResult => {
7+
const customRender = (ui: ReactElement<any>, options?: Omit<RenderOptions, 'queries'>): RenderResult => {
88
const TestWrapper: FunctionComponent<PropsWithChildren> = ({children}) => (
99
<Plasmantine withCssVariables={false}>{children}</Plasmantine>
1010
);

packages/mantine/src/components/button/ButtonWithDisabledTooltip.tsx

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Box, Tooltip, TooltipProps} from '@mantine/core';
2-
import {ReactNode, forwardRef} from 'react';
2+
import {FunctionComponent, ReactNode} from 'react';
33

44
import {createPolymorphicComponent} from '../../utils';
55

@@ -23,18 +23,23 @@ export interface ButtonWithDisabledTooltipProps {
2323
fullWidth?: boolean;
2424
}
2525

26-
const _ButtonWithDisabledTooltip = forwardRef<HTMLDivElement, ButtonWithDisabledTooltipProps>(
27-
({disabledTooltip, disabled, children, disabledTooltipProps, fullWidth, ...others}, ref) =>
28-
disabledTooltip ? (
29-
<Tooltip label={disabledTooltip} disabled={!disabled} {...disabledTooltipProps}>
30-
<Box ref={ref} style={{'&:hover': {cursor: 'not-allowed'}, width: fullWidth && '100%'}} {...others}>
31-
{children}
32-
</Box>
33-
</Tooltip>
34-
) : (
35-
<>{children}</>
36-
),
37-
);
26+
const _ButtonWithDisabledTooltip: FunctionComponent<ButtonWithDisabledTooltipProps> = ({
27+
disabledTooltip,
28+
disabled,
29+
children,
30+
disabledTooltipProps,
31+
fullWidth,
32+
...others
33+
}) =>
34+
disabledTooltip ? (
35+
<Tooltip label={disabledTooltip} disabled={!disabled} {...disabledTooltipProps}>
36+
<Box style={{'&:hover': {cursor: 'not-allowed'}, width: fullWidth && '100%'}} {...others}>
37+
{children}
38+
</Box>
39+
</Tooltip>
40+
) : (
41+
<>{children}</>
42+
);
3843

3944
export const ButtonWithDisabledTooltip = createPolymorphicComponent<'div', ButtonWithDisabledTooltipProps>(
4045
_ButtonWithDisabledTooltip,

packages/mantine/src/components/ellipsis-text/EllipsisText.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const EllipsisText = polymorphicFactory<EllipsisTextFactory>((props, ref)
5252
});
5353

5454
const [showTooltip, setShowTooltip] = useState(false);
55-
const textRef = useRef<HTMLDivElement>();
55+
const textRef = useRef<HTMLDivElement>(null);
5656

5757
const {className: rootClass, ...rootStyles} = getStyles('root');
5858
const {className: textClass, ...textStyles} = getStyles('text');

packages/mantine/src/components/header/Header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const Header = factory<HeaderFactory>((_props, ref) => {
9999
});
100100
const stylesApiProps = {classNames, styles};
101101

102-
const convertedChildren = Children.toArray(children) as ReactElement[];
102+
const convertedChildren = Children.toArray(children) as ReactElement<any>[];
103103
const breadcrumbs = convertedChildren.find((child) => child.type === HeaderBreadcrumbs);
104104
const actions = convertedChildren.find((child) => child.type === HeaderActions);
105105
const docAnchor = convertedChildren.find((child) => child.type === HeaderDocAnchor);

packages/mantine/src/components/header/__tests__/__snapshots__/Header.spec.tsx.snap

-73
This file was deleted.

packages/mantine/src/components/inline-confirm/InlineConfirm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const InlineConfirm = ((_props) => {
3737
const {children} = useProps('InlineConfirm', defaultProps, _props);
3838
const [confirmingId, setConfirmingId] = useState<string | null>(null);
3939

40-
const convertedChildren = Children.toArray(children) as ReactElement[];
40+
const convertedChildren = Children.toArray(children) as ReactElement<any>[];
4141
const prompt = convertedChildren.find(
4242
(child) => child.type !== InlineConfirmTarget && child.props?.inlineConfirmId === confirmingId,
4343
);

packages/mantine/src/components/inline-confirm/InlineConfirmPrompt.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ interface InlineConfirmPromptProps extends Omit<GroupProps, 'children'>, InlineC
1717
*
1818
* @default <Button color="red">Delete</Button>
1919
*/
20-
confirm?: ReactElement;
20+
confirm?: ReactElement<{onClick?: () => void}>;
2121
/**
2222
* Cancel button element
2323
*
2424
* @default <Button variant="outline">Cancel</Button>
2525
*/
26-
cancel?: ReactElement;
26+
cancel?: ReactElement<{onClick?: () => void}>;
2727
/**
2828
* Function called when the confirm button is clicked
2929
*/

packages/mantine/src/components/prompt/Prompt.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const Prompt = factory<PromptFactory>((_props, ref) => {
9292
});
9393
const stylesApiProps = {classNames, styles};
9494

95-
const convertedChildren = Children.toArray(children) as ReactElement[];
95+
const convertedChildren = Children.toArray(children) as ReactElement<any>[];
9696

9797
const otherChildren = convertedChildren.filter((child) => child.type !== PromptFooter);
9898
const footer = convertedChildren.find((child) => child.type === PromptFooter);

packages/mantine/src/components/table/Table.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export const Table = <T,>(props: TableProps<T> & {ref?: ForwardedRef<HTMLDivElem
125125
unstyled,
126126
});
127127

128-
const convertedChildren = Children.toArray(children) as ReactElement[];
128+
const convertedChildren = Children.toArray(children) as ReactElement<any>[];
129129
const header = convertedChildren.find((child) => child.type === TableHeader);
130130
const footer = convertedChildren.find((child) => child.type === TableFooter);
131131
const lastUpdated = convertedChildren.find((child) => child.type === TableLastUpdated);
@@ -213,7 +213,7 @@ export const Table = <T,>(props: TableProps<T> & {ref?: ForwardedRef<HTMLDivElem
213213
}
214214
}, [data]);
215215

216-
const containerRef = useRef<HTMLDivElement>();
216+
const containerRef = useRef<HTMLDivElement>(null);
217217
useClickOutside(
218218
() => {
219219
if (!store.multiRowSelectionEnabled && store.getSelectedRows().length > 0) {

packages/mantine/src/components/table/Table.types.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type TableLayoutProps<TData = unknown> = Pick<
1313
TableProps<TData>['layoutProps'];
1414

1515
export interface TableLayout {
16-
(props: {children: ReactNode}): ReactElement;
16+
(props: {children: ReactNode}): ReactElement<any>;
1717
/**
1818
* Name of the layout.
1919
* Will be displayed in the layout control
@@ -28,12 +28,12 @@ export interface TableLayout {
2828
* Header portion of the table.
2929
* In the standard row layout that is where column headers would be displayed.
3030
*/
31-
Header: <TData>(props: TableLayoutProps<TData>) => ReactElement;
31+
Header: <TData>(props: TableLayoutProps<TData>) => ReactElement<any>;
3232
/**
3333
* Body portion of the table.
3434
* In the standard row layout that is where the rows would be displayed.
3535
*/
36-
Body: <TData>(props: TableLayoutProps<TData>) => ReactElement;
36+
Body: <TData>(props: TableLayoutProps<TData>) => ReactElement<any>;
3737
}
3838

3939
export interface TableProps<TData> extends BoxProps, StylesApiProps<PlasmaTableFactory> {

packages/mantine/src/components/table/TableContext.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {createSafeContext, GetStylesApi} from '@mantine/core';
22
import {Table} from '@tanstack/table-core';
3-
import {MutableRefObject, ReactElement} from 'react';
3+
import {MutableRefObject, ReactElement, type JSX} from 'react';
44
import {type PlasmaTableFactory} from './Table';
55
import {TableAction, TableLayout} from './Table.types';
66
import {TableStore} from './use-table';
@@ -21,4 +21,4 @@ export interface TableProviderProps<T> {
2121

2222
export const [TableProvider, useTableContext] = createSafeContext<TableContextValue>(
2323
'Table component was not found in the tree',
24-
) as [<TData>(props: TableProviderProps<TData>) => ReactElement, <TData>() => TableContextValue<TData>];
24+
) as [<TData>(props: TableProviderProps<TData>) => ReactElement<any>, <TData>() => TableContextValue<TData>];

packages/mantine/src/components/table/table-actions/TableHeaderActions.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type TableHeaderActionsFactory = Factory<{
1919
const defaultProps: Partial<TableHeaderActionsProps> = {};
2020

2121
export const TableHeaderActions = factory<TableHeaderActionsFactory>(
22-
(props: TableHeaderActionsProps, ref): ReactElement => {
22+
(props: TableHeaderActionsProps, ref): ReactElement<any> => {
2323
const {store, getStyles, getRowActions} = useTableContext();
2424
const {style, className, classNames, styles, ...others} = useProps(
2525
'PlasmaTableHeaderActions',

packages/mantine/src/hooks/useParentHeight.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const getElementInnerHeight = (el: HTMLElement): number => {
1313
*/
1414
export const useParentHeight = (): [number, MutableRefObject<HTMLDivElement>] => {
1515
const [height, setHeight] = useState(-1);
16-
const ref = useRef<HTMLDivElement>();
16+
const ref = useRef<HTMLDivElement>(null);
1717

1818
useEffect(() => {
1919
if (ref.current) {

packages/website/package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
"@coveord/plasma-react-icons": "workspace:*",
2020
"@coveord/plasma-tokens": "workspace:*",
2121
"@faker-js/faker": "9.3.0",
22-
"@mantine/code-highlight": "7.14.3",
23-
"@mantine/core": "7.14.3",
24-
"@mantine/dates": "7.14.3",
25-
"@mantine/form": "7.14.3",
26-
"@mantine/hooks": "7.14.3",
27-
"@mantine/modals": "7.14.3",
28-
"@mantine/notifications": "7.14.3",
22+
"@mantine/code-highlight": "7.15.1",
23+
"@mantine/core": "7.15.1",
24+
"@mantine/dates": "7.15.1",
25+
"@mantine/form": "7.15.1",
26+
"@mantine/hooks": "7.15.1",
27+
"@mantine/modals": "7.15.1",
28+
"@mantine/notifications": "7.15.1",
2929
"@mantinex/dev-icons": "1.0.2",
3030
"@stencil/core": "4.22.3",
3131
"@swc/helpers": "0.5.15",

0 commit comments

Comments
 (0)