diff --git a/.changeset/rude-cycles-scream.md b/.changeset/rude-cycles-scream.md new file mode 100644 index 00000000000..6d413c9a591 --- /dev/null +++ b/.changeset/rude-cycles-scream.md @@ -0,0 +1,5 @@ +--- +'@primer/react': major +--- + +Remove the sx prop from RadioGroup and Truncate. diff --git a/packages/react/src/ActionList/Description.tsx b/packages/react/src/ActionList/Description.tsx index 2db37e74ac7..c4624c6f061 100644 --- a/packages/react/src/ActionList/Description.tsx +++ b/packages/react/src/ActionList/Description.tsx @@ -61,7 +61,6 @@ export const Description: React.FC { secondaryAction={Button} /> { setSelected(selected as Choice) }} + className={classes.RadioGroupWithTopMargin} > Choices diff --git a/packages/react/src/RadioGroup/RadioGroup.tsx b/packages/react/src/RadioGroup/RadioGroup.tsx index d6de96490e0..cc9b64b78b0 100644 --- a/packages/react/src/RadioGroup/RadioGroup.tsx +++ b/packages/react/src/RadioGroup/RadioGroup.tsx @@ -7,9 +7,8 @@ import CheckboxOrRadioGroupCaption from '../internal/components/CheckboxOrRadioG import CheckboxOrRadioGroupLabel from '../internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupLabel' import CheckboxOrRadioGroupValidation from '../internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupValidation' import {useRenderForcingRef} from '../hooks' -import type {SxProp} from '../sx' -type RadioGroupProps = { +export type RadioGroupProps = { /** * An onChange handler that gets called when the selection changes */ @@ -18,8 +17,7 @@ type RadioGroupProps = { * The name used to identify this group of radios */ name: string -} & CheckboxOrRadioGroupProps & - SxProp +} & CheckboxOrRadioGroupProps export const RadioGroupContext = createContext<{ disabled?: boolean diff --git a/packages/react/src/RadioGroup/index.ts b/packages/react/src/RadioGroup/index.ts index d29db1c955a..7c2be01c513 100644 --- a/packages/react/src/RadioGroup/index.ts +++ b/packages/react/src/RadioGroup/index.ts @@ -1 +1,3 @@ export {default, RadioGroupContext} from './RadioGroup' + +export type {RadioGroupProps} from './RadioGroup' diff --git a/packages/react/src/Truncate/Truncate.stories.tsx b/packages/react/src/Truncate/Truncate.stories.tsx index 0f1d0b24e27..ea95707c01e 100644 --- a/packages/react/src/Truncate/Truncate.stories.tsx +++ b/packages/react/src/Truncate/Truncate.stories.tsx @@ -41,12 +41,6 @@ Playground.argTypes = { disable: true, }, }, - sx: { - controls: false, - table: { - disable: true, - }, - }, theme: { controls: false, table: { diff --git a/packages/react/src/Truncate/Truncate.tsx b/packages/react/src/Truncate/Truncate.tsx index 4ece1eaf59f..e9c3e27e9cd 100644 --- a/packages/react/src/Truncate/Truncate.tsx +++ b/packages/react/src/Truncate/Truncate.tsx @@ -1,27 +1,23 @@ import React from 'react' import {clsx} from 'clsx' import type {MaxWidthProps} from 'styled-system' -import type {SxProp} from '../sx' import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic' -import {BoxWithFallback} from '../internal/components/BoxWithFallback' import classes from './Truncate.module.css' type TruncateProps = React.HTMLAttributes & { title: string inline?: boolean expandable?: boolean -} & MaxWidthProps & - SxProp +} & MaxWidthProps const Truncate = React.forwardRef(function Truncate( - {as, children, className, title, inline, expandable, maxWidth = 125, style, sx, ...rest}, + {as: Component = 'div', children, className, title, inline, expandable, maxWidth = 125, style, ...rest}, ref, ) { return ( - {children} - + ) }) as PolymorphicForwardRefComponent<'div', TruncateProps> diff --git a/packages/react/src/__tests__/__snapshots__/exports.test.ts.snap b/packages/react/src/__tests__/__snapshots__/exports.test.ts.snap index 9b12e24fb87..a043ac85029 100644 --- a/packages/react/src/__tests__/__snapshots__/exports.test.ts.snap +++ b/packages/react/src/__tests__/__snapshots__/exports.test.ts.snap @@ -124,6 +124,7 @@ exports[`@primer/react > should not update exports without a semver change 1`] = "type ProgressBarProps", "Radio", "RadioGroup", + "type RadioGroupProps", "type RadioProps", "registerPortalRoot", "RelativeTime", diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index 8fd81d2c9dd..d7b4f74ac40 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -129,6 +129,7 @@ export type {PortalProps} from './Portal' export {ProgressBar} from './ProgressBar' export type {ProgressBarProps, ProgressBarItemProps} from './ProgressBar' export {default as RadioGroup} from './RadioGroup' +export type {RadioGroupProps} from './RadioGroup' export type {RelativeTimeProps} from './RelativeTime' export {default as RelativeTime} from './RelativeTime' export {SegmentedControl} from './SegmentedControl' diff --git a/packages/styled-react/src/index.tsx b/packages/styled-react/src/index.tsx index 23411aec0c1..329e9064bb9 100644 --- a/packages/styled-react/src/index.tsx +++ b/packages/styled-react/src/index.tsx @@ -3,6 +3,8 @@ import { Box, type BoxProps, type SxProp, + RadioGroup as PrimerRadioGroup, + type RadioGroupProps as PrimerRadioGroupProps, Checkbox as PrimerCheckbox, type CheckboxProps as PrimerCheckboxProps, CounterLabel as PrimerCounterLabel, @@ -14,6 +16,8 @@ import { type SubNavLinkProps as PrimerSubNavLinkProps, ToggleSwitch as PrimerToggleSwitch, type ToggleSwitchProps as PrimerToggleSwitchProps, + Truncate as PrimerTruncate, + type TruncateProps as PrimerTruncateProps, type SegmentedControlProps as PrimerSegmentedControlProps, SegmentedControl as PrimerSegmentedControl, type SegmentedControlButtonProps as PrimerSegmentedControlButtonProps, @@ -23,7 +27,9 @@ import { type UnderlineNavItemProps as PrimerUnderlineNavItemProps, sx, } from '@primer/react' -import React, {type PropsWithChildren, forwardRef} from 'react' +import React, {forwardRef, type PropsWithChildren} from 'react' +import type {ForwardRefComponent} from './polymorphic' + import type { BackgroundProps, BorderProps, @@ -37,7 +43,7 @@ import type { TypographyProps, } from 'styled-system' import styled from 'styled-components' -import type {ForwardRefComponent} from './polymorphic' + import {LinkButton, type LinkButtonProps} from './components/LinkButton' type StyledProps = SxProp & @@ -52,6 +58,48 @@ type StyledProps = SxProp & PositionProps & ShadowProps +type RadioGroupProps = PropsWithChildren & SxProp + +const RadioGroupImpl = (props: RadioGroupProps) => { + return +} + +// Define local types based on the internal component props +type CheckboxOrRadioGroupLabelProps = PropsWithChildren< + { + className?: string + visuallyHidden?: boolean + } & SxProp +> +const CheckboxOrRadioGroupLabel = (props: CheckboxOrRadioGroupLabelProps) => { + return +} + +type CheckboxOrRadioGroupCaptionProps = PropsWithChildren< + { + className?: string + } & SxProp +> +const CheckboxOrRadioGroupCaption = (props: CheckboxOrRadioGroupCaptionProps) => { + return +} + +type CheckboxOrRadioGroupValidationProps = PropsWithChildren< + { + className?: string + variant: 'error' | 'success' + } & SxProp +> +const CheckboxOrRadioGroupValidation = (props: CheckboxOrRadioGroupValidationProps) => { + return +} + +const RadioGroup = Object.assign(RadioGroupImpl, { + Label: CheckboxOrRadioGroupLabel, + Caption: CheckboxOrRadioGroupCaption, + Validation: CheckboxOrRadioGroupValidation, +}) + type SegmentedControlProps = PropsWithChildren & SxProp type SegmentedControlButtonProps = PropsWithChildren & SxProp type SegmentedControlIconButtonProps = PropsWithChildren & SxProp @@ -113,6 +161,14 @@ const ToggleSwitch = forwardRef(function T return }) +type TruncateProps = PropsWithChildren & SxProp + +const Truncate: ForwardRefComponent<'div', TruncateProps> = styled(PrimerTruncate).withConfig({ + shouldForwardProp: prop => prop !== 'sx', +})` + ${sx} +` + type UnderlineNavProps = PrimerUnderlineNavProps & SxProp const UnderlineNavImpl = forwardRef(function UnderlineNav(props, ref) { @@ -138,10 +194,12 @@ export { type LinkButtonProps, Checkbox, CounterLabel, + RadioGroup, SegmentedControl, StateLabel, SubNav, ToggleSwitch, + Truncate, UnderlineNav, } @@ -168,7 +226,6 @@ export { PageHeader, PageLayout, ProgressBar, - RadioGroup, RelativeTime, Select, Spinner, @@ -180,8 +237,6 @@ export { Token, type TokenProps, Tooltip, - Truncate, - // styled-components components or types Box, sx,