diff --git a/package.json b/package.json index 7446ea88848..249bb1a936d 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "new-github-release-url": "^1.0.0", "next": "^12.2.0", "open": "^8.2.0", - "prettier": "^2.7.1", + "prettier": "^2.4.1", "react-beautiful-dnd": "^13.1.0", "react-docgen-typescript": "2.1.0", "react-dom": "18.1.0", diff --git a/src/mantine-carousel/src/Carousel.tsx b/src/mantine-carousel/src/Carousel.tsx index f5cf368fe8b..39ab41976e7 100644 --- a/src/mantine-carousel/src/Carousel.tsx +++ b/src/mantine-carousel/src/Carousel.tsx @@ -344,7 +344,6 @@ _Carousel.Slide = CarouselSlide; _Carousel.displayName = '@mantine/carousel/Carousel'; export const Carousel: ForwardRefWithStaticComponents< - HTMLDivElement, CarouselProps, { Slide: typeof CarouselSlide } > = _Carousel; diff --git a/src/mantine-core/src/AppShell/Aside/Aside.tsx b/src/mantine-core/src/AppShell/Aside/Aside.tsx index cfdbd7dbf79..59bce899bfe 100644 --- a/src/mantine-core/src/AppShell/Aside/Aside.tsx +++ b/src/mantine-core/src/AppShell/Aside/Aside.tsx @@ -9,16 +9,12 @@ import { Section } from '../HorizontalSection/Section/Section'; export interface AsideProps extends HorizontalSectionSharedProps, - React.ComponentPropsWithoutRef<'nav'> { + React.ComponentPropsWithRef<'nav'> { /** Aside content */ children: React.ReactNode; } -type AsideComponent = ForwardRefWithStaticComponents< - HTMLElement, - AsideProps, - { Section: typeof Section } ->; +type AsideComponent = ForwardRefWithStaticComponents; const defaultProps: Partial = { fixed: false, diff --git a/src/mantine-core/src/AppShell/HorizontalSection/HorizontalSection.tsx b/src/mantine-core/src/AppShell/HorizontalSection/HorizontalSection.tsx index 79560b2c347..8ee7a37137c 100644 --- a/src/mantine-core/src/AppShell/HorizontalSection/HorizontalSection.tsx +++ b/src/mantine-core/src/AppShell/HorizontalSection/HorizontalSection.tsx @@ -39,7 +39,7 @@ export interface HorizontalSectionSharedProps extends DefaultProps { export interface HorizontalSectionProps extends HorizontalSectionSharedProps, - Omit, 'children'> { + Omit, 'children'> { section: 'navbar' | 'aside'; __staticSelector: string; } diff --git a/src/mantine-core/src/AppShell/Navbar/Navbar.tsx b/src/mantine-core/src/AppShell/Navbar/Navbar.tsx index 48371a1378d..751ad6cfb2f 100644 --- a/src/mantine-core/src/AppShell/Navbar/Navbar.tsx +++ b/src/mantine-core/src/AppShell/Navbar/Navbar.tsx @@ -9,16 +9,12 @@ import { Section } from '../HorizontalSection/Section/Section'; export interface NavbarProps extends HorizontalSectionSharedProps, - React.ComponentPropsWithoutRef<'nav'> { + React.ComponentPropsWithRef<'nav'> { /** Navbar content */ children: React.ReactNode; } -type NavbarComponent = ForwardRefWithStaticComponents< - HTMLElement, - NavbarProps, - { Section: typeof Section } ->; +type NavbarComponent = ForwardRefWithStaticComponents; const defaultProps: Partial = { fixed: false, diff --git a/src/mantine-core/src/Checkbox/Checkbox.tsx b/src/mantine-core/src/Checkbox/Checkbox.tsx index ce3d29e6935..7a62e7e06f9 100644 --- a/src/mantine-core/src/Checkbox/Checkbox.tsx +++ b/src/mantine-core/src/Checkbox/Checkbox.tsx @@ -20,7 +20,7 @@ export type CheckboxStylesNames = Selectors; export interface CheckboxProps extends DefaultProps, - Omit, 'type' | 'size'> { + Omit, 'type' | 'size'> { /** Key of theme.colors */ color?: MantineColor; @@ -56,7 +56,6 @@ const defaultProps: Partial = { }; type CheckboxComponent = ForwardRefWithStaticComponents< - HTMLInputElement, CheckboxProps, { Group: typeof CheckboxGroup } >; diff --git a/src/mantine-core/src/Chip/Chip.tsx b/src/mantine-core/src/Chip/Chip.tsx index bbec06f1767..951dcb40dd5 100644 --- a/src/mantine-core/src/Chip/Chip.tsx +++ b/src/mantine-core/src/Chip/Chip.tsx @@ -20,7 +20,7 @@ export type ChipStylesNames = Selectors; export interface ChipProps extends DefaultProps, - Omit, 'size' | 'onChange'> { + Omit, 'size' | 'onChange'> { /** Chip radius from theme or number to set value in px */ radius?: MantineNumberSize; @@ -62,11 +62,7 @@ const defaultProps: Partial = { variant: 'outline', }; -type ChipComponent = ForwardRefWithStaticComponents< - HTMLInputElement, - ChipProps, - { Group: typeof ChipGroup } ->; +type ChipComponent = ForwardRefWithStaticComponents; export const Chip: ChipComponent = forwardRef((props, ref) => { const { diff --git a/src/mantine-core/src/Grid/Grid.test.tsx b/src/mantine-core/src/Grid/Grid.test.tsx index a6183fb51f1..a0032cd0f71 100644 --- a/src/mantine-core/src/Grid/Grid.test.tsx +++ b/src/mantine-core/src/Grid/Grid.test.tsx @@ -26,15 +26,6 @@ describe('@mantine/core/Grid', () => { expect(Grid.Col).toBe(Col); }); - it('supports getting Grid ref', () => { - const ref = React.createRef(); - render( - - - - ); - expect(ref.current instanceof HTMLDivElement).toBe(true); - }); it('supports getting Col ref', () => { const ref = React.createRef(); render( diff --git a/src/mantine-core/src/Grid/Grid.tsx b/src/mantine-core/src/Grid/Grid.tsx index 1f41d75c794..4024c44be3c 100644 --- a/src/mantine-core/src/Grid/Grid.tsx +++ b/src/mantine-core/src/Grid/Grid.tsx @@ -6,7 +6,7 @@ import { Col } from './Col/Col'; import { GridProvider } from './Grid.context'; import useStyles from './Grid.styles'; -export interface GridProps extends DefaultProps, React.ComponentPropsWithoutRef<'div'> { +export interface GridProps extends DefaultProps, React.ComponentPropsWithRef<'div'> { /** components only */ children: React.ReactNode; @@ -26,7 +26,7 @@ export interface GridProps extends DefaultProps, React.ComponentPropsWithoutRef< columns?: number; } -type GridComponent = ForwardRefWithStaticComponents; +type GridComponent = ForwardRefWithStaticComponents; const defaultProps: Partial = { gutter: 'md', diff --git a/src/mantine-core/src/List/List.tsx b/src/mantine-core/src/List/List.tsx index 4a6e3118a00..2815192c069 100644 --- a/src/mantine-core/src/List/List.tsx +++ b/src/mantine-core/src/List/List.tsx @@ -42,11 +42,7 @@ export interface ListProps listStyleType?: React.CSSProperties['listStyleType']; } -type ListComponent = ForwardRefWithStaticComponents< - HTMLUListElement, - ListProps, - { Item: typeof ListItem } ->; +type ListComponent = ForwardRefWithStaticComponents; const defaultProps: Partial = { type: 'unordered', diff --git a/src/mantine-core/src/Radio/Radio.tsx b/src/mantine-core/src/Radio/Radio.tsx index ff6df714b1e..d3b04621b64 100644 --- a/src/mantine-core/src/Radio/Radio.tsx +++ b/src/mantine-core/src/Radio/Radio.tsx @@ -19,7 +19,7 @@ export type RadioStylesNames = Selectors; export interface RadioProps extends DefaultProps, - Omit, 'size'> { + Omit, 'size'> { /** Radio label */ label?: React.ReactNode; @@ -48,11 +48,7 @@ const defaultProps: Partial = { size: 'sm', }; -type RadioComponent = ForwardRefWithStaticComponents< - HTMLInputElement, - RadioProps, - { Group: typeof RadioGroup } ->; +type RadioComponent = ForwardRefWithStaticComponents; export const Radio: RadioComponent = forwardRef((props, ref) => { const { diff --git a/src/mantine-core/src/ScrollArea/ScrollArea.tsx b/src/mantine-core/src/ScrollArea/ScrollArea.tsx index 1d23cbced33..365bc6afbc3 100644 --- a/src/mantine-core/src/ScrollArea/ScrollArea.tsx +++ b/src/mantine-core/src/ScrollArea/ScrollArea.tsx @@ -164,7 +164,6 @@ _ScrollArea.displayName = '@mantine/core/ScrollArea'; _ScrollArea.Autosize = ScrollAreaAutosize; export const ScrollArea: ForwardRefWithStaticComponents< - HTMLDivElement, ScrollAreaProps, { Autosize: typeof ScrollAreaAutosize; diff --git a/src/mantine-core/src/Stepper/Stepper.tsx b/src/mantine-core/src/Stepper/Stepper.tsx index a9a3195e487..30406e4284d 100644 --- a/src/mantine-core/src/Stepper/Stepper.tsx +++ b/src/mantine-core/src/Stepper/Stepper.tsx @@ -17,7 +17,7 @@ export type StepperStylesNames = Selectors | StepStylesNames; export interface StepperProps extends DefaultProps, - React.ComponentPropsWithoutRef<'div'> { + React.ComponentPropsWithRef<'div'> { /** components only */ children: React.ReactNode; @@ -59,7 +59,6 @@ export interface StepperProps } type StepperComponent = ForwardRefWithStaticComponents< - HTMLDivElement, StepperProps, { Step: typeof Step; diff --git a/src/mantine-core/src/Switch/Switch.tsx b/src/mantine-core/src/Switch/Switch.tsx index 396b2512562..0d4c87c098d 100644 --- a/src/mantine-core/src/Switch/Switch.tsx +++ b/src/mantine-core/src/Switch/Switch.tsx @@ -55,11 +55,7 @@ const defaultProps: Partial = { radius: 'xl', }; -type SwitchComponent = ForwardRefWithStaticComponents< - HTMLInputElement, - SwitchProps, - { Group: typeof SwitchGroup } ->; +type SwitchComponent = ForwardRefWithStaticComponents; export const Switch: SwitchComponent = forwardRef((props, ref) => { const { diff --git a/src/mantine-core/src/Tabs/Tabs.tsx b/src/mantine-core/src/Tabs/Tabs.tsx index 3d69452ff8a..6f2c11f0653 100644 --- a/src/mantine-core/src/Tabs/Tabs.tsx +++ b/src/mantine-core/src/Tabs/Tabs.tsx @@ -26,7 +26,6 @@ export interface TabsProps Omit, keyof TabsProviderProps> {} type TabsComponent = ForwardRefWithStaticComponents< - HTMLDivElement, TabsProps, { List: typeof TabsList; diff --git a/src/mantine-core/src/Timeline/Timeline.test.tsx b/src/mantine-core/src/Timeline/Timeline.test.tsx index 183ba96834c..dea706ba844 100644 --- a/src/mantine-core/src/Timeline/Timeline.test.tsx +++ b/src/mantine-core/src/Timeline/Timeline.test.tsx @@ -39,12 +39,6 @@ describe('@mantine/core/Timeline', () => { ); }); - it('supports getting Timeline ref', () => { - const ref = React.createRef(); - render(); - expect(ref.current instanceof HTMLDivElement).toBe(true); - }); - it('exposes TimelineItem as Timeline.Item', () => { expect(Timeline.Item).toBe(TimelineItem); }); diff --git a/src/mantine-core/src/Timeline/Timeline.tsx b/src/mantine-core/src/Timeline/Timeline.tsx index ab727774f96..2e827a5fa34 100644 --- a/src/mantine-core/src/Timeline/Timeline.tsx +++ b/src/mantine-core/src/Timeline/Timeline.tsx @@ -12,7 +12,7 @@ import { TimelineItem, TimelineItemStylesNames } from './TimelineItem/TimelineIt export interface TimelineProps extends DefaultProps, - React.ComponentPropsWithoutRef<'div'> { + React.ComponentPropsWithRef<'div'> { /** components only */ children: React.ReactNode; @@ -39,7 +39,6 @@ export interface TimelineProps } type TimelineComponent = ForwardRefWithStaticComponents< - HTMLDivElement, TimelineProps, { Item: typeof TimelineItem } >; diff --git a/src/mantine-core/src/Tooltip/Tooltip.tsx b/src/mantine-core/src/Tooltip/Tooltip.tsx index 54da20e52dc..ee3116efdf2 100644 --- a/src/mantine-core/src/Tooltip/Tooltip.tsx +++ b/src/mantine-core/src/Tooltip/Tooltip.tsx @@ -188,7 +188,6 @@ _Tooltip.Floating = TooltipFloating; _Tooltip.displayName = '@mantine/core/Tooltip'; export const Tooltip: ForwardRefWithStaticComponents< - HTMLElement, TooltipProps, { Group: typeof TooltipGroup; Floating: typeof TooltipFloating } > = _Tooltip; diff --git a/src/mantine-dropzone/src/Dropzone.tsx b/src/mantine-dropzone/src/Dropzone.tsx index 4e992f3d408..bd3422c3d42 100644 --- a/src/mantine-dropzone/src/Dropzone.tsx +++ b/src/mantine-dropzone/src/Dropzone.tsx @@ -19,7 +19,7 @@ export type DropzoneStylesNames = Selectors; export interface DropzoneProps extends DefaultProps, - Omit, 'onDrop'> { + Omit, 'onDrop'> { /** Padding from theme.spacing, or number to set padding in px */ padding?: MantineNumberSize; @@ -199,7 +199,6 @@ _Dropzone.Reject = DropzoneReject; _Dropzone.Idle = DropzoneIdle; export const Dropzone: ForwardRefWithStaticComponents< - HTMLDivElement, DropzoneProps, { Accept: typeof DropzoneAccept; diff --git a/src/mantine-prism/src/Prism/Prism.tsx b/src/mantine-prism/src/Prism/Prism.tsx index 7ac62d85ac0..61aa229f5b7 100644 --- a/src/mantine-prism/src/Prism/Prism.tsx +++ b/src/mantine-prism/src/Prism/Prism.tsx @@ -22,7 +22,7 @@ export type PrismStylesNames = Selectors; export interface PrismProps extends DefaultProps, - Omit, 'children'> { + Omit, 'children'> { /** Code which will be highlighted */ children: string; diff --git a/src/mantine-prism/src/index.ts b/src/mantine-prism/src/index.ts index d2685381458..f4808deba50 100644 --- a/src/mantine-prism/src/index.ts +++ b/src/mantine-prism/src/index.ts @@ -9,7 +9,6 @@ export type { PrismProps, PrismStylesNames } from './Prism/Prism'; export type { PrismStylesParams } from './Prism/Prism.styles'; type PrismComponent = ForwardRefWithStaticComponents< - HTMLDivElement, PrismProps, { Tabs: typeof PrismTabs; diff --git a/src/mantine-utils/src/ForwardRefWithStaticComponents.ts b/src/mantine-utils/src/ForwardRefWithStaticComponents.ts index 7636ffb8518..c5c937d21e9 100644 --- a/src/mantine-utils/src/ForwardRefWithStaticComponents.ts +++ b/src/mantine-utils/src/ForwardRefWithStaticComponents.ts @@ -1,7 +1,7 @@ -import { forwardRef } from 'react'; - export type ForwardRefWithStaticComponents< - T, Props extends Record, Static extends Record -> = ReturnType> & Static; +> = ((props: Props) => React.ReactElement) & + Static & { + displayName: string; + }; diff --git a/yarn.lock b/yarn.lock index 1cfe9ba0661..04b7d5f53cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11376,10 +11376,10 @@ prepend-http@^1.0.0: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.0.tgz#b6a5bf1284026ae640f17f7ff5658a7567fc0d18" integrity sha512-kXtO4s0Lz/DW/IJ9QdWhAf7/NmPWQXkFr/r/WkR3vyI+0v8amTDxiaQSLzs8NBlytfLWX/7uQUMIW677yLKl4w== -prettier@^2.7.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" - integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== +prettier@^2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.1.tgz#671e11c89c14a4cfc876ce564106c4a6726c9f5c" + integrity sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA== pretty-error@^2.1.1: version "2.1.2"