Skip to content

Commit 42705e3

Browse files
author
Sasha Kondrashov
committed
input
1 parent 563a73a commit 42705e3

File tree

5 files changed

+10
-18
lines changed

5 files changed

+10
-18
lines changed

index.d.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,7 @@ export {
254254
StrictImageGroupProps,
255255
} from './dist/commonjs/elements/Image/ImageGroup'
256256

257-
export {
258-
default as Input,
259-
InputProps,
260-
InputOnChangeData,
261-
StrictInputProps,
262-
} from './dist/commonjs/elements/Input'
257+
export { default as Input, InputProps, StrictInputProps } from './dist/commonjs/elements/Input'
263258

264259
export { default as Label, LabelProps, StrictLabelProps } from './dist/commonjs/elements/Label'
265260
export {

src/elements/Input/Input.d.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ export interface StrictInputProps {
6060
* Called on change.
6161
*
6262
* @param {ChangeEvent} event - React's original SyntheticEvent.
63-
* @param {object} data - All props and a proposed value.
63+
* @param {object} props - All props.
64+
* @param {string} value - The value of the input.
6465
*/
65-
onChange?: (event: React.ChangeEvent<HTMLInputElement>, data: InputOnChangeData) => void
66+
onChange?: (event: React.ChangeEvent<HTMLInputElement>, props: InputProps, value: string) => void
6667

6768
/** An Input can vary in size. */
6869
size?: 'mini' | 'small' | 'large' | 'big' | 'huge' | 'massive'
@@ -77,10 +78,6 @@ export interface StrictInputProps {
7778
type?: string
7879
}
7980

80-
export interface InputOnChangeData extends InputProps {
81-
value: string
82-
}
83-
8481
declare const Input: ForwardRefComponent<InputProps, HTMLInputElement>
8582

8683
export default Input

src/elements/Input/Input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const Input = React.forwardRef(function (props, ref) {
7272
const handleChange = (e) => {
7373
const newValue = _.get(e, 'target.value')
7474

75-
_.invoke(props, 'onChange', e, { ...props, value: newValue })
75+
_.invoke(props, 'onChange', e, props, newValue)
7676
}
7777

7878
const partitionProps = () => {

src/elements/Input/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default, InputProps, StrictInputProps, InputOnChangeData } from './Input'
1+
export { default, InputProps, StrictInputProps } from './Input'

test/specs/elements/Input/Input-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe('Input', () => {
170170
})
171171

172172
describe('onChange', () => {
173-
it('is called with (e, data) on change', () => {
173+
it('is called on change', () => {
174174
const onChange = sandbox.spy()
175175
const e = { target: { value: 'name' } }
176176
const props = { 'data-foo': 'bar', onChange }
@@ -180,10 +180,10 @@ describe('Input', () => {
180180
wrapper.find('input').simulate('change', e)
181181

182182
onChange.should.have.been.calledOnce()
183-
onChange.should.have.been.calledWithMatch(e, { ...props, value: e.target.value })
183+
onChange.should.have.been.calledWithMatch(e, props, e.target.value)
184184
})
185185

186-
it('is called with (e, data) on change when using children', () => {
186+
it('is called on change when using children', () => {
187187
const onChange = sandbox.spy()
188188
const e = { target: { value: 'name' } }
189189
const props = { 'data-foo': 'bar', onChange }
@@ -197,7 +197,7 @@ describe('Input', () => {
197197
wrapper.find('input').simulate('change', e)
198198

199199
onChange.should.have.been.calledOnce()
200-
onChange.should.have.been.calledWithMatch(e, { ...props, value: e.target.value })
200+
onChange.should.have.been.calledWithMatch(e, props, e.target.value)
201201
})
202202
})
203203

0 commit comments

Comments
 (0)