From cd4b4e3112dcd084891162ad856a0793fdbc3795 Mon Sep 17 00:00:00 2001 From: HerilS Date: Mon, 7 Nov 2022 23:48:28 -0700 Subject: [PATCH] feat(components/input): polymorphic attribs to input component --- src/lib/Button/Button.tsx | 10 ++++++---- src/lib/Input/Input.tsx | 11 ++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/lib/Button/Button.tsx b/src/lib/Button/Button.tsx index 87e7f49..b5894d8 100644 --- a/src/lib/Button/Button.tsx +++ b/src/lib/Button/Button.tsx @@ -10,7 +10,8 @@ import ButtonIcon from './ButtonIcon'; /** * Buttons allow users to take actions, and make choices, with a single tap. */ -export interface ButtonProps extends React.ComponentPropsWithRef<'button'> { +export interface ButtonProps + extends React.ComponentPropsWithRef<'button'> { /** * The content of the component. */ @@ -84,7 +85,7 @@ export interface ButtonProps extends React.Componen } const Button = React.forwardRef( - ( + ( { role = 'button', as, @@ -103,7 +104,8 @@ const Button = React.forwardRef( children, pill = false, ...btnProps - }: ButtonProps & Omit, keyof ButtonProps>, + }: ButtonProps & + Omit, keyof ButtonProps>, ref: React.Ref ) => { const hasText = useMemo( @@ -129,7 +131,7 @@ const Button = React.forwardRef( const preClass = 'decaButton'; const { dark } = React.useContext(ThemeContext); - + return ( extends Modify< React.ComponentPropsWithRef<'input'>, { @@ -58,7 +58,7 @@ export interface InputProps /** * Changes which tag component outputs. */ - as?: keyof JSX.IntrinsicElements; + as?: T; /** * Placeholder text for component. */ @@ -114,14 +114,14 @@ export interface InputProps } const Input = React.forwardRef( - ( + ( { label, className = '', disabled = false, size = 'md', variant = 'solid', - as = 'input', + as, css, focusColor = 'primary', maxWidth = false, @@ -135,7 +135,8 @@ const Input = React.forwardRef( onBlur, pill = false, ...props - }: InputProps, + }: InputProps & + Omit, keyof InputProps>, ref: React.Ref ) => { const inputRef = useRef>(null);