Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,26 @@ import {
customPropTypes,
getUnhandledProps,
partitionHTMLProps,
UIComponent,
} from '../../lib'
import Icon from '../Icon'
import { ComponentVariablesInput, IComponentPartStylesInput } from '../../../types/theme'
import { ReactChildren, Extendable, ItemShorthand } from '../../../types/utils'

export interface IInputProps {
as?: any
children?: ReactChildren
className?: string
clearable?: boolean
defaultValue?: string
fluid?: boolean
icon?: ItemShorthand
input?: ItemShorthand
onChange?: (event: React.SyntheticEvent, data: IInputProps) => void
value?: string
type?: string
styles?: IComponentPartStylesInput
variables?: ComponentVariablesInput
}

/**
* An Input
Expand All @@ -23,7 +40,7 @@ import Icon from '../Icon'
* - if input is search, then use "role='search'"
*
*/
class Input extends AutoControlledComponent<any, any> {
class Input extends AutoControlledComponent<Extendable<IInputProps>, any> {
static className = 'ui-input'

static displayName = 'Input'
Expand Down Expand Up @@ -118,7 +135,6 @@ class Input extends AutoControlledComponent<any, any> {

handleOnClear = e => {
const { clearable } = this.props
const { value } = this.state

if (clearable) {
this.trySetState({ value: '' })
Expand Down Expand Up @@ -169,11 +185,10 @@ class Input extends AutoControlledComponent<any, any> {
}

renderComponent({ ElementType, classes, rest, styles }) {
const { children, clearable, input, type } = this.props
const { children, input, type } = this.props
const [htmlInputProps, restProps] = this.partitionProps()

const inputClasses = classes.input
const iconClasses = classes.icon

// Render with children
// ----------------------------------------
Expand Down