From 345fb7503a9f40e1137f5f9b8a34b6ffbf8436ba Mon Sep 17 00:00:00 2001 From: Marie Lucca Date: Thu, 2 Oct 2025 18:59:41 -0400 Subject: [PATCH 1/9] chore: rmeove unnecessary sx prop migrations --- .../src/components/FormControl.tsx | 27 +++++-------------- .../src/components/PageLayout.tsx | 18 ++----------- 2 files changed, 8 insertions(+), 37 deletions(-) diff --git a/packages/styled-react/src/components/FormControl.tsx b/packages/styled-react/src/components/FormControl.tsx index b4affd914be..1e087a44afb 100644 --- a/packages/styled-react/src/components/FormControl.tsx +++ b/packages/styled-react/src/components/FormControl.tsx @@ -14,30 +14,15 @@ const FormControlImpl = forwardRef(function Fo return }) -type FormControlCaptionProps = PropsWithChildren & SxProp -const FormControlCaption = (props: FormControlCaptionProps) => { - return -} - -type FormControlValidationProps = PropsWithChildren & SxProp - -const FormControlValidation = (props: FormControlValidationProps) => { - return -} - -const FormControlLeadingVisual = (props: PropsWithChildren) => { - return -} - const FormControl = Object.assign(FormControlImpl, { - Caption: FormControlCaption, - LeadingVisual: FormControlLeadingVisual, - Validation: FormControlValidation, + Caption: PrimerFormControl.Caption, + LeadingVisual: PrimerFormControl.LeadingVisual, + Validation: PrimerFormControl.Validation, Label: PrimerFormControl.Label, }) as typeof FormControlImpl & { - Caption: typeof FormControlCaption - LeadingVisual: typeof FormControlLeadingVisual - Validation: typeof FormControlValidation + Caption: typeof PrimerFormControl.Caption + LeadingVisual: typeof PrimerFormControl.LeadingVisual + Validation: typeof PrimerFormControl.Validation Label: typeof PrimerFormControl.Label } diff --git a/packages/styled-react/src/components/PageLayout.tsx b/packages/styled-react/src/components/PageLayout.tsx index de4670c6528..619db31a7d1 100644 --- a/packages/styled-react/src/components/PageLayout.tsx +++ b/packages/styled-react/src/components/PageLayout.tsx @@ -27,31 +27,17 @@ const PageLayoutContent = React.forwardRef }) -type PageLayoutHeaderProps = PropsWithChildren & SxProp - -const PageLayoutHeader = React.forwardRef((props, ref) => { - // @ts-expect-error - PrimerPageLayout.Header is not recognized as a valid component type - return -}) - type PageLayoutPaneProps = PropsWithChildren & SxProp const PageLayoutPane = React.forwardRef((props, ref) => { return }) -type PageLayoutFooterProps = PropsWithChildren & SxProp - -const PageLayoutFooter = React.forwardRef((props, ref) => { - // @ts-expect-error - PrimerPageLayout.Footer is not recognized as a valid component type - return -}) - const PageLayout = Object.assign(PageLayoutImpl, { Content: PageLayoutContent, - Header: PageLayoutHeader, + Header: PrimerPageLayout.Header, Pane: PageLayoutPane, - Footer: PageLayoutFooter, + Footer: PrimerPageLayout.Footer, }) export {PageLayout, type PageLayoutProps} From 97eb6a2e2147e3e133b3041a6b308a4b3db38661 Mon Sep 17 00:00:00 2001 From: Marie Lucca Date: Thu, 2 Oct 2025 19:13:01 -0400 Subject: [PATCH 2/9] support style in FormControl subcomponents --- .../src/FormControl/FormControlCaption.tsx | 4 +++- .../react/src/FormControl/FormControlLabel.tsx | 16 +++++++++++++++- .../FormControl/FormControlLeadingVisual.tsx | 7 ++++++- .../src/FormControl/_FormControlValidation.tsx | 13 +++++++++---- .../src/internal/components/InputLabel.tsx | 5 +++-- .../internal/components/InputValidation.tsx | 18 ++++++++++++++---- 6 files changed, 50 insertions(+), 13 deletions(-) diff --git a/packages/react/src/FormControl/FormControlCaption.tsx b/packages/react/src/FormControl/FormControlCaption.tsx index d01b2bd710e..ac96260c2d0 100644 --- a/packages/react/src/FormControl/FormControlCaption.tsx +++ b/packages/react/src/FormControl/FormControlCaption.tsx @@ -7,9 +7,10 @@ import {useFormControlContext} from './_FormControlContext' export type FormControlCaptionProps = React.PropsWithChildren<{ id?: string className?: string + style?: React.CSSProperties }> -function FormControlCaption({id, children, className}: FormControlCaptionProps) { +function FormControlCaption({id, children, className, style}: FormControlCaptionProps) { const {captionId, disabled} = useFormControlContext() return ( @@ -17,6 +18,7 @@ function FormControlCaption({id, children, className}: FormControlCaptionProps) id={id ?? captionId} className={clsx(className, classes.Caption)} data-control-disabled={disabled ? '' : undefined} + style={style} > {children} diff --git a/packages/react/src/FormControl/FormControlLabel.tsx b/packages/react/src/FormControl/FormControlLabel.tsx index 59b6f4a5fcd..e35dc9bc1a0 100644 --- a/packages/react/src/FormControl/FormControlLabel.tsx +++ b/packages/react/src/FormControl/FormControlLabel.tsx @@ -11,11 +11,23 @@ export type Props = { requiredIndicator?: boolean id?: string className?: string + style?: React.CSSProperties } const FormControlLabel: React.FC< React.PropsWithChildren<{htmlFor?: string} & React.ComponentProps & Props> -> = ({as, children, htmlFor, id, visuallyHidden, requiredIndicator = true, requiredText, className, ...props}) => { +> = ({ + as, + children, + htmlFor, + id, + visuallyHidden, + requiredIndicator = true, + requiredText, + className, + style, + ...props +}) => { const {disabled, id: formControlId, required} = useFormControlContext() /** @@ -27,6 +39,7 @@ const FormControlLabel: React.FC< as, id, className, + style, visuallyHidden, required, requiredText, @@ -38,6 +51,7 @@ const FormControlLabel: React.FC< as, id, className, + style, visuallyHidden, htmlFor: htmlFor || formControlId, required, diff --git a/packages/react/src/FormControl/FormControlLeadingVisual.tsx b/packages/react/src/FormControl/FormControlLeadingVisual.tsx index fa253d1aa4f..6f009e4b442 100644 --- a/packages/react/src/FormControl/FormControlLeadingVisual.tsx +++ b/packages/react/src/FormControl/FormControlLeadingVisual.tsx @@ -1,14 +1,19 @@ import type React from 'react' import {useFormControlContext} from './_FormControlContext' import classes from './FormControlLeadingVisual.module.css' +import type {HTMLAttributes} from 'react' -const FormControlLeadingVisual: React.FC = ({children}) => { +const FormControlLeadingVisual: React.FC & HTMLAttributes = ({ + children, + ...props +}) => { const {disabled, captionId} = useFormControlContext() return (
{children}
diff --git a/packages/react/src/FormControl/_FormControlValidation.tsx b/packages/react/src/FormControl/_FormControlValidation.tsx index 4c3610128ad..0c58021a400 100644 --- a/packages/react/src/FormControl/_FormControlValidation.tsx +++ b/packages/react/src/FormControl/_FormControlValidation.tsx @@ -1,6 +1,5 @@ import type React from 'react' import InputValidation from '../internal/components/InputValidation' -import type {SxProp} from '../sx' import type {FormValidationStatus} from '../utils/types/FormValidationStatus' import {useFormControlContext} from './_FormControlContext' @@ -8,18 +7,24 @@ export type FormControlValidationProps = { variant: FormValidationStatus id?: string className?: string -} & SxProp + style?: React.CSSProperties +} const FormControlValidation: React.FC> = ({ children, className, variant, - sx, id, + style, }) => { const {validationMessageId} = useFormControlContext() return ( - + {children} ) diff --git a/packages/react/src/internal/components/InputLabel.tsx b/packages/react/src/internal/components/InputLabel.tsx index 63e7bf86086..5543966be6a 100644 --- a/packages/react/src/internal/components/InputLabel.tsx +++ b/packages/react/src/internal/components/InputLabel.tsx @@ -12,6 +12,7 @@ type BaseProps = SxProp & { visuallyHidden?: boolean id?: string className?: string + style?: React.CSSProperties } export type LabelProps = BaseProps & { @@ -35,16 +36,16 @@ function InputLabel({ requiredText, requiredIndicator, visuallyHidden, - sx, as = 'label', className, + style, ...props }: Props) { return ( // @ts-ignore weird typing issue with union for `as` prop , @@ -21,7 +21,13 @@ const validationIconMap: Record< error: AlertFillIcon, } -const InputValidation: React.FC> = ({children, className, id, validationStatus}) => { +const InputValidation: React.FC> = ({ + children, + className, + id, + validationStatus, + style: inlineStyle, +}) => { const IconComponent = validationStatus ? validationIconMap[validationStatus] : undefined // TODO: use `text-caption-lineHeight` token as a custom property when it's available @@ -31,7 +37,11 @@ const InputValidation: React.FC> = ({children, cl const iconBoxMinHeight = iconSize * captionLineHeight return ( - + {IconComponent ? (