Skip to content

Commit 7a9493b

Browse files
committed
Update to deprecate props
1 parent a97371d commit 7a9493b

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

.changeset/clean-ligers-approve.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@primer/react": minor
33
---
44

5-
Remove width props from TextInput
5+
Deprecate width, minWidth and maxWidth props from TextInput

packages/react/src/TextInput/TextInput.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@ export type TextInputNonPassthroughProps = {
4141
trailingAction?: React.ReactElement<React.HTMLProps<HTMLButtonElement>>
4242
} & Pick<
4343
StyledWrapperProps,
44-
'block' | 'contrast' | 'disabled' | 'monospace' | 'sx' | 'width' | 'variant' | 'size' | 'validationStatus'
44+
| 'block'
45+
| 'contrast'
46+
| 'disabled'
47+
| 'monospace'
48+
| 'sx'
49+
| 'width'
50+
| 'maxWidth'
51+
| 'minWidth'
52+
| 'variant'
53+
| 'size'
54+
| 'validationStatus'
4555
>
4656

4757
export type TextInputProps = Merge<React.ComponentPropsWithoutRef<'input'>, TextInputNonPassthroughProps>
@@ -69,6 +79,8 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
6979
onBlur,
7080
// start deprecated props
7181
width: widthProp,
82+
minWidth: minWidthProp,
83+
maxWidth: maxWidthProp,
7284
variant: variantProp,
7385
// end deprecated props
7486
type = 'text',
@@ -126,6 +138,8 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
126138
sx={sxProp}
127139
size={sizeProp}
128140
width={widthProp}
141+
minWidth={minWidthProp}
142+
maxWidth={maxWidthProp}
129143
variant={variantProp}
130144
hasLeadingVisual={Boolean(LeadingVisual || showLeadingLoadingIndicator)}
131145
hasTrailingVisual={Boolean(TrailingVisual || showTrailingLoadingIndicator)}

packages/react/src/TextInputWithTokens/TextInputWithTokens.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
9191
hideTokenRemoveButtons = false,
9292
maxHeight,
9393
width: widthProp,
94+
minWidth: minWidthProp,
95+
maxWidth: maxWidthProp,
9496
validationStatus,
9597
variant: variantProp, // deprecated. use `size` instead
9698
visibleTokenCount,
@@ -262,6 +264,8 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
262264
hasLeadingVisual={Boolean(LeadingVisual || showLeadingLoadingIndicator)}
263265
hasTrailingVisual={Boolean(TrailingVisual || showTrailingLoadingIndicator)}
264266
width={widthProp}
267+
minWidth={minWidthProp}
268+
maxWidth={maxWidthProp}
265269
size={inputSizeMap[size]}
266270
validationStatus={validationStatus}
267271
variant={variantProp} // deprecated. use `size` prop instead

packages/react/src/internal/components/TextInputWrapper.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import styled, {css} from 'styled-components'
2-
import {variant} from 'styled-system'
2+
import type {MaxWidthProps, MinWidthProps, WidthProps} from 'styled-system'
3+
import {maxWidth, minWidth, variant, width} from 'styled-system'
34
import {get} from '../../constants'
45
import type {SxProp} from '../../sx'
56
import sx from '../../sx'
@@ -55,8 +56,10 @@ export type StyledBaseWrapperProps = {
5556
isInputFocused?: boolean
5657
monospace?: boolean
5758
validationStatus?: FormValidationStatus
58-
width?: string
59-
} & SxProp
59+
} & /** @deprecated Update `width` using CSS modules or style. */ WidthProps &
60+
/** @deprecated Update `min-width` using CSS modules or style. */ MinWidthProps &
61+
/** @deprecated Update `max-width` using CSS modules or style. */ MaxWidthProps &
62+
SxProp
6063

6164
export type StyledWrapperProps = {
6265
hasLeadingVisual?: boolean
@@ -176,17 +179,14 @@ export const TextInputBaseWrapper = styled.span<StyledBaseWrapperProps>`
176179
align-self: stretch;
177180
`}
178181
179-
${props =>
180-
props.width &&
181-
css`
182-
width: ${props.width};
183-
`}
184-
185182
// Ensures inputs don' t zoom on mobile but are body-font size on desktop
186183
@media (min-width: ${get('breakpoints.1')}) {
187184
font-size: ${get('fontSizes.1')};
188185
}
189186
187+
${width}
188+
${minWidth}
189+
${maxWidth}
190190
${sizeDeprecatedVariants}
191191
${sizeVariants}
192192
${sx};

0 commit comments

Comments
 (0)