-
Notifications
You must be signed in to change notification settings - Fork 670
chore(TextInput): remove sx #6925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 18 commits
48181d7
75c5b50
bc30458
3d10343
607edd3
a573acd
1b33c3d
4b20d80
05785b5
7f53ab9
07be57e
beb0fb1
a251708
b55c591
b03bc50
c3f6d97
6cc3368
d98b6c6
861ffc8
55488c7
d52d8b7
f09d16f
f81329e
aab2106
f524327
8f0bdff
b249971
9418ca0
b3808a3
f5a18ab
94bad6f
5dbabf9
44d0471
b1732d1
3a0cb7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@primer/react": patch | ||
| "@primer/styled-react": patch | ||
| --- | ||
|
|
||
| chore(TextInput): remove sx |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export {default} from './TextInput' | ||
| export type {TextInputProps, TextInputNonPassthroughProps} from './TextInput' | ||
| export type {TextInputActionProps} from '../internal/components/TextInputInnerAction' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { | ||
| TextInput as PrimerTextInput, | ||
| type TextInputProps as PrimerTextInputProps, | ||
| type TextInputActionProps as PrimerTextInputActionProps, | ||
| } from '@primer/react' | ||
| import {forwardRef} from 'react' | ||
| import {Box} from './Box' | ||
| import type {SxProp} from '../sx' | ||
| import type {ForwardRefExoticComponent, RefAttributes} from 'react' | ||
|
|
||
| export type TextInputProps = PrimerTextInputProps & SxProp & {as?: React.ElementType} | ||
| export type TextInputActionProps = PrimerTextInputActionProps & SxProp | ||
|
|
||
| const StyledTextInput = forwardRef<HTMLInputElement, TextInputProps>((props, ref) => { | ||
| return <Box as={PrimerTextInput} ref={ref} {...props} /> | ||
| }) | ||
|
|
||
| const TextInputImpl = forwardRef<HTMLInputElement, TextInputProps>(({as, ...props}, ref) => { | ||
| return <StyledTextInput ref={ref} {...props} {...(as ? {forwardedAs: as} : {})} /> | ||
|
francinelucca marked this conversation as resolved.
|
||
| }) | ||
|
|
||
| const TextInputAction = forwardRef<HTMLButtonElement, TextInputActionProps>((props, ref) => { | ||
| return <Box as={PrimerTextInput.Action} ref={ref} {...props} /> | ||
| }) | ||
|
|
||
| type TextInputComposite = ForwardRefExoticComponent<TextInputProps & RefAttributes<HTMLInputElement>> & { | ||
| Action: typeof TextInputAction | ||
| } | ||
|
|
||
| export const TextInput: TextInputComposite = Object.assign(TextInputImpl, { | ||
| Action: TextInputAction, | ||
| }) | ||
|
Comment on lines
+35
to
+37
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note the approach we are using with component-wrapping is not compatible with some child type comparisons we do in some parts of the codebase (for example, inputComponent identification in FormControl) and these components will not work in this context. In this PR, this affects TextInput and Textarea. |
||
|
|
||
| TextInputAction.displayName = 'TextInputAction' | ||
| TextInputImpl.displayName = 'TextInput' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import {Textarea as PrimerTextarea, type TextareaProps as PrimerTextareaProps} from '@primer/react' | ||
| import styled from 'styled-components' | ||
| import {sx, type SxProp} from '../sx' | ||
| import type {ForwardRefComponent} from '../polymorphic' | ||
| import {forwardRef} from 'react' | ||
|
|
||
| type TextareaProps = PrimerTextareaProps & SxProp & {as?: React.ElementType} | ||
|
|
||
| const StyledTextarea = styled(PrimerTextarea).withConfig<TextareaProps>({ | ||
| shouldForwardProp: prop => prop !== 'sx', | ||
| })` | ||
| ${sx} | ||
| ` as ForwardRefComponent<'textarea', TextareaProps> | ||
|
|
||
| const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(({as, ...props}, ref) => { | ||
| return <StyledTextarea {...props} {...(as ? {forwardedAs: as} : {})} ref={ref} /> | ||
| }) as ForwardRefComponent<'textarea', TextareaProps> | ||
|
|
||
| export {Textarea, type TextareaProps} |
Uh oh!
There was an error while loading. Please reload this page.