@@ -10,20 +10,26 @@ import {sx, type SxProp} from '../sx'
1010import type { ForwardRefComponent } from '../polymorphic'
1111import { Box } from './Box'
1212import type { PropsWithChildren } from 'react'
13+ import React from 'react'
1314
1415type PageHeaderProps = PrimerPageHeaderProps & SxProp
1516
16- const PageHeaderImpl : ForwardRefComponent < 'div' , PageHeaderProps > = styled (
17+ const StyledPageHeader : ForwardRefComponent < 'div' , PageHeaderProps > = styled (
1718 PrimerPageHeader ,
1819) . withConfig < PageHeaderProps > ( {
1920 shouldForwardProp : prop => prop !== 'sx' ,
2021} ) `
2122 ${ sx }
2223`
2324
25+ const PageHeaderImpl = React . forwardRef < HTMLDivElement , PageHeaderProps > ( ( { as, ...props } , ref ) => (
26+ // @ts -ignore forwardedAs is valid here but I don't know how to fix the typescript error
27+ < StyledPageHeader forwardedAs = { as } ref = { ref } { ...props } />
28+ ) ) as ForwardRefComponent < 'div' , PageHeaderProps >
29+
2430type PageHeaderActionsProps = PrimerPageHeaderActionsProps & SxProp
2531
26- function PageHeaderActions ( { sx, ...rest } : PageHeaderActionsProps ) {
32+ function StyledPageHeaderActions ( { sx, ...rest } : PageHeaderActionsProps ) {
2733 const style : CSSCustomProperties = { }
2834 if ( sx ) {
2935 // @ts -ignore sx has height attribute
@@ -37,13 +43,16 @@ function PageHeaderActions({sx, ...rest}: PageHeaderActionsProps) {
3743 return < Box { ...rest } as = { PrimerPageHeader . Actions } style = { style } sx = { sx } />
3844}
3945
46+ // @ts -ignore forwardedAs is valid here but I don't know how to fix the typescript error
47+ const PageHeaderActions = ( { as, ...props } : PageHeaderProps ) => < StyledPageHeaderActions forwardedAs = { as } { ...props } />
48+
4049type PageHeaderTitleProps = PropsWithChildren < PrimerPageHeaderTitleProps > & SxProp
4150
4251type CSSCustomProperties = {
4352 [ key : `--${string } `] : string | number
4453}
4554
46- function PageHeaderTitle ( { sx, ...rest } : PageHeaderTitleProps ) {
55+ function StyledPageHeaderTitle ( { sx, ...rest } : PageHeaderTitleProps ) {
4756 const style : CSSCustomProperties = { }
4857 if ( sx ) {
4958 // @ts -ignore sx can have color attribute
@@ -65,6 +74,9 @@ function PageHeaderTitle({sx, ...rest}: PageHeaderTitleProps) {
6574 return < Box { ...rest } as = { PrimerPageHeader . Title } style = { style } sx = { sx } />
6675}
6776
77+ // @ts -ignore forwardedAs is valid here but I don't know how to fix the typescript error
78+ const PageHeaderTitle = ( { as, ...props } : PageHeaderTitleProps ) => < StyledPageHeaderTitle forwardedAs = { as } { ...props } />
79+
6880type PageHeaderTitleAreaProps = PropsWithChildren < PrimerPageHeaderTitleAreaProps > & SxProp
6981
7082const PageHeaderTitleArea : ForwardRefComponent < 'div' , PageHeaderTitleAreaProps > = styled (
@@ -75,7 +87,7 @@ const PageHeaderTitleArea: ForwardRefComponent<'div', PageHeaderTitleAreaProps>
7587 ${ sx }
7688`
7789
78- type PageHeaderComponent = ForwardRefComponent < 'div' , PageHeaderProps > & {
90+ type PageHeaderComponentType = ForwardRefComponent < 'div' , PageHeaderProps > & {
7991 Actions : typeof PageHeaderActions
8092 ContextArea : typeof PrimerPageHeader . ContextArea
8193 ParentLink : typeof PrimerPageHeader . ParentLink
@@ -91,7 +103,7 @@ type PageHeaderComponent = ForwardRefComponent<'div', PageHeaderProps> & {
91103 TrailingAction : typeof PrimerPageHeader . TrailingAction
92104}
93105
94- const PageHeader : PageHeaderComponent = Object . assign ( PageHeaderImpl , {
106+ const PageHeader : PageHeaderComponentType = Object . assign ( PageHeaderImpl , {
95107 Actions : PageHeaderActions ,
96108 ContextArea : PrimerPageHeader . ContextArea ,
97109 ParentLink : PrimerPageHeader . ParentLink ,
0 commit comments